<?php
/**
 * Created by PhpStorm.
 * User: liuhong
 * Date: 2018/11/15
 * Time: 下午1:52
 */

namespace Common\Service;


class GradeService extends BaseService
{
    protected $gradeModel;

    public function __construct()
    {
        $this->gradeModel=M('grade');
    }/*ccc*/

    /**
     * 等级名称
     * @param $grade_id
     * @return mixed
     */
    public function backGradeName($grade_id){
        $gradeInfo=$this->gradeModel->select();
        $newGrade=array();
        foreach ($gradeInfo as $k=>$v){
            $newGrade[$v['grade_id']]=$v['grade_name'];
        }
        return $newGrade[$grade_id];
    }

    /**
     * 返回等级列表
     * @param $filed
     * @param $where
     * @return mixed
     */
    public function gradeList($where=array(),$filed=null){
        if(!empty($filed)){
            return $this->gradeModel->field($filed)->where($where)->order('ord asc')->select();
        }else{
            return $this->gradeModel->where($where)->order('ord asc')->select();
        }
    }

}